<%--
  Created by IntelliJ IDEA.
  User: 小军伟
  Date: 2019/11/1
  Time: 15:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录界面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="${pageContext.request.contextPath}/ico/aaa.ico" rel="SHORTCUT ICON">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">

    <%--<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">--%>
    <script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
</head>
<body>
<form enctype="application/x-www-form-urlencoded" method="post" action="${pageContext.request.contextPath}/login">
    用户名：<input type="text" name="username" id="username">
    密码： <input type="password" name="password" id="password">
    验证码<input type="text" name="code" id="code">
    <img src="${pageContext.request.contextPath}/captcha" id="vcode"><label id="checkMsg"></label><br>
    <input type="submit" value="登录" id="login">
</form>
<script type="text/javascript">
    $(function () {
        $("#vcode").click(function () {
            $("#vcode").attr("src","${pageContext.request.contextPath}/captcha?"+new Date().getTime());
        })

        $("#code").change(function () {
            var value = $(this).val();
            // alert(value);
            $.post("${pageContext.request.contextPath}/checkCode","vcode="+value, function (data) {
                    if(data=="0"){
                        $("#checkMsg").html("<font color='green'>OK</font>");
                        $("#login").show();
                    }else{
                        $("#checkMsg").html("<font color='red'>ERROR</font>");
                        $("#login").hide();
                        $("#vcode").attr("src","${pageContext.request.contextPath}/captcha?"+new Date().getTime());
                    }
                }
            )
        })

    })
</script>
</body>
</html>
